package com.hcb.tonguetiphealth.view;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.hcb.tonguetiphealth.widget.homepage.HomepagePersonalWidget;

public class PicShowActivity extends AbstractActivity {

	private Activity ctx;
	private LinearLayout llBack;
	private ImageView img;
	private String fileName;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.pic_show);
		ctx = this;
		fileName = getIntent().getStringExtra("fileName");
		bindView();
		bindEvent();
	}

	private void bindView() {
		img = (ImageView)findViewById(R.id.img);
		llBack = (LinearLayout)findViewById(R.id.head_portrait_back);
		FileInputStream fis;
		try {
			fis = new FileInputStream(fileName);
			Bitmap bitmap = BitmapFactory.decodeStream(fis);
			Drawable drawable = new BitmapDrawable(bitmap);
			img.setBackgroundDrawable(drawable);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	private void bindEvent() {
	 
		llBack.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				ctx.finish();
			}
		});
	}

	@Override
	public void onBackPressed() {
		finish();
	}
	
}